<template>
	<view>
		  <view class="cu-list menu-avatar  card-menu martop" >

		    <view class="cu-item" v-for="(item,index) in lists" :key="index">
				<image class="cu-avatar round lg " :src='item.icon'   @tap="toUserMain(item._id)"></image>

		      <view class="content">
		        <view class="text-grey">
		          <text class="text-cut">{{item.user_name}}</text>
<!-- 		          <view class="cu-tag round bg-orange sm">战士</view> -->
		        </view>
		        <view class="text-gray text-sm flex">
		          <text class="text-cut">{{item.characters.slice(0,2)+"..."}}</text>
		        </view>
		      </view>
		      <view class="action"  @tap="toChat(item._id,item.user_name,item.icon)">
		        <view class="text-grey text-xs btn-c">
					聊天
				</view>
<!-- 		        <view class="cuIcon-notice_forbid_fill text-gray"></view> -->
		      </view>
		    </view>
		  </view>
		  <view class="loading" v-if="loading">
		       <text>加载中,等一小下</text>
		       <view class="rect"></view>
		  </view>
		<!-- 聊天消息end -->
	</view>
</template>

<script>
	import store from '../../../globalStore/store.json'
	import data from '../../../datas/data.json'
	export default {
		data() {
			return {
				lists:[],
				user_id:"",
				loading:false
			}
		},
		onLoad(options) {
			this.user_id=options.user_id;
			var that=this;
			this.loading=true;
			uniCloud.callFunction({
				name:"getAllFocusers",
				data:{
					"user_id":that.user_id
				},
				success(res) {
					that.lists=res.result.lists;
					that.loading=false;
				},fail(err) {
					console.log(err)
				}
			})
			// let user=store.user;
			// let focused_users=user.focused_users;
			// let all_users=data.users;
			// for(let j=0; j<focused_users.length; j++){
			// 	let tmp = focused_users[j];
			// 	for(let i=0; i<all_users.length; i++){
			// 		if(all_users[i].user_id==tmp){
			// 			this.lists.push(all_users[i]);
			// 		}
			// 	}
			// }
		},
		onShow() {
			uni.setNavigationBarTitle({
				title:"我的关注"
			})	
		},
		methods: {
			toChat:function(id,name,icon){
				 uni.navigateTo({
					url:"../../msg/msg_chat/msg_chat?friend_id="+id+"&friend_name="+name+"&icon="+icon
				 })
			},
			toUserMain(id){
				 uni.navigateTo({
					url:'../../user-detail/user-detail?user_id='+id
				 })
			},
		}
	}
</script>

<style scoped>
	.icon{
		width: 50px;
		height: 50px;
		border-radius: 50px 50px;
	}

	.btn-c{
		background: #3287e4;
		color: white;
	}
</style>